function y = kden(x,data)

ny = length(data);
nx = length(x);
y  = zeros(nx,1);

h = 1.06*ny^(-1/5)*std(data);

for i=1:nx
   y(i) = 1/(ny*h)*sum( normpdf( (ones(ny,1)*x(i)-data)/h ) );
end
